home *** CD-ROM | disk | FTP | other *** search
- package sun.plugin;
-
- import java.net.URL;
- import java.util.Hashtable;
- import sun.applet.AppletPanel;
-
- class ClassLoaderInfo {
- private static Hashtable infos = new Hashtable();
- private URL codebase;
- private int references = 0;
- private Hashtable jars;
- private boolean locked;
- private static boolean initialized;
- private static boolean cacheJars = true;
-
- private static synchronized void initialize() {
- if (!initialized) {
- initialized = true;
- int var0 = Integer.getInteger("javaplugin.jar.cache.size", 100);
- if (var0 > 0) {
- cacheJars = true;
- System.err.println("JAR cache enabled.");
- } else {
- cacheJars = false;
- System.err.println("JAR cache disabled.");
- }
- }
- }
-
- static synchronized ClassLoaderInfo find(AppletPanel var0) {
- initialize();
- URL var1 = var0.getCodeBase();
- ClassLoaderInfo var2 = (ClassLoaderInfo)infos.get(var1);
- if (var2 == null) {
- var2 = new ClassLoaderInfo(var1);
- infos.put(var1, var2);
- }
-
- return var2;
- }
-
- synchronized void addReference() {
- ++this.references;
- }
-
- synchronized void removeReference() {
- --this.references;
- if (this.references < 0) {
- throw new Error("negative ref count???");
- } else {
- if (this.references == 0 && !cacheJars) {
- infos.remove(this.codebase);
- AppletPanel.flushClassLoader(this.codebase);
- }
-
- }
- }
-
- private ClassLoaderInfo(URL var1) {
- this.codebase = var1;
- this.jars = new Hashtable();
- }
-
- synchronized void addJar(String var1) {
- this.jars.put(var1, var1);
- }
-
- synchronized boolean hasJar(String var1) {
- return this.jars.get(var1) != null;
- }
-
- public final synchronized void lock() throws InterruptedException {
- while(this.locked) {
- this.wait();
- }
-
- this.locked = true;
- }
-
- public final synchronized void unlock() {
- this.locked = false;
- this.notifyAll();
- }
- }
-